home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / FORTRAN / EXAMPLE.F next >
Encoding:
Text File  |  1998-08-12  |  2.4 KB  |  115 lines

  1.  
  2. C  Copyright (c) Mark J. Kilgard, 1994.
  3.  
  4. C  This program is freely distributable without licensing fees
  5. C  and is provided without guarantee or warrantee expressed or
  6. C  implied.  This program is -not- in the public domain.
  7.  
  8. C  GLUT Fortran example; touches a reasonable amount of GLUT
  9. C  callback functionality.
  10.  
  11.     subroutine display
  12. #include "GL/fgl.h"
  13.     call fglclear(GL_COLOR_BUFFER_BIT)
  14.     call fglfinish
  15.     end
  16.  
  17.     subroutine passive(x,y)
  18.     integer x,y
  19.     print *,'passive motion',x,y
  20.     end
  21.  
  22.     subroutine submenu(value)
  23.     integer value
  24.     print *,'value is',value
  25.     end
  26.  
  27.     subroutine mainmenu(value)
  28.     integer value
  29.     print *,'main menu value is',value
  30.     end
  31.  
  32.     subroutine timer(value)
  33.     integer value
  34.     print *,'timer value',value
  35.     end
  36.  
  37.     subroutine mouse(btn,state,x,y)
  38. #include "GL/fglut.h"
  39.     external timer
  40.     integer btn,state,x,y
  41.     print *,'mouse',btn,state,x,y
  42.     call gluttimerfunc(1000,timer,25)
  43.     end
  44.  
  45.     subroutine idle()
  46. #include "GL/fglut.h"
  47.     integer count
  48.     print *,'idle called'
  49.     call glutidlefunc(glutnull)
  50.     end
  51.  
  52.     subroutine keyboard(key,x,y)
  53.     external idle
  54.     integer key,x,y
  55.     print *,'keyboard',key,x,y
  56.     call glutidlefunc(idle)
  57.     end
  58.  
  59.     subroutine tablet(x,y)
  60.     integer x,y
  61.     print *,'tablet motion',x,y
  62.     end
  63.  
  64.     subroutine tbutton(button,state)
  65.     integer button,state
  66.     print *,'tablet button',button,state
  67.     end
  68.  
  69.     subroutine dials(dial,value)
  70.     integer dial,value
  71.     print *,'dial movement',dial,value
  72.     end
  73.  
  74.     subroutine box(button,state)
  75.     integer button,state
  76.     print *,'button box',button,state
  77.     end
  78.  
  79.     program main
  80. #include "GL/fglut.h"
  81.     external display
  82.     external passive
  83.     external submenu
  84.     external mainmenu
  85.     external mouse
  86.     external keyboard
  87.     external tablet
  88.     external tbutton
  89.     external dials
  90.     external box
  91.     call glutinit
  92.     print *,glutcreatewindow('Fortran GLUT program')
  93.     call glutdisplayfunc(display)
  94.     call glutpassivemotionfunc(passive)
  95.     call glutmousefunc(mouse)
  96.     call glutkeyboardfunc(keyboard)
  97.     call gluttabletmotionfunc(tablet)
  98.     call gluttabletbuttonfunc(tbutton)
  99.     call glutdialsfunc(dials)
  100.     call glutbuttonboxfunc(box)
  101.     i = glutcreatemenu(submenu)
  102.     call glutaddmenuentry('something', 4)
  103.     call glutaddmenuentry('another thing', 5)
  104.     j = glutcreatemenu(mainmenu)
  105.     call glutaddsubmenu('submenu', i)
  106.     call glutaddmenuentry('quit', 666)
  107.     call glutattachmenu(2)
  108.     print *,'Number of button box buttons:',
  109.      2    glutdeviceget(GLUT_NUM_BUTTON_BOX_BUTTONS)
  110.     print *,'Number of dials:',glutdeviceget(GLUT_NUM_DIALS)
  111.     print *,'Depth buffer size',glutget(GLUT_WINDOW_DEPTH_SIZE)
  112.     call glutmainloop
  113.     end
  114.  
  115.